/*
 * Copyright 2021-2030 itbox.cn All right reserved. This software is the confidential and proprietary information
 * of itbox.cn ("Confidential Information"). You shall not disclose such Confidential Information and shall use it
 * only in accordance with the terms of the license agreement you entered into with itbox.cn.
 */
package cn.itbox.example.service;

import cn.itbox.example.model.request.CreateUserRequest;
import cn.itbox.example.model.request.UpdateUserRequest;
import cn.itbox.example.model.request.UserPageRequest;
import cn.itbox.example.model.response.UserResponse;
import cn.itbox.uap.domain.annotation.AutoController;
import cn.itbox.uap.db.model.PageResult;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @BelongProject springboot-study
 * @BelongPackage cn.itbox.example.application.service
 * @Description TODO
 * @ClassName UserService
 * @Author xingc
 * @Date 2023/11/26 23:09
 * @Version 1.0.0
 */
@AutoController
@RequestMapping("/user")
public interface UserService {
    /**
     * 新建用户
     * @param request
     * @return
     */
    @PostMapping
    Long create(@RequestBody @Valid CreateUserRequest request);

    /**
     * 修改用户
     * @param request
     */
    @PutMapping
    void update(@RequestBody @Valid UpdateUserRequest request);

    /**
     * 删除用户
     * @param id
     */
    @DeleteMapping("/{id}")
    void delete(@PathVariable(value = "id") Long id);

    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    UserResponse byId(@PathVariable(value = "id") Long id);

    /**
     * 用户所有数据查询
     * @return
     */
    @GetMapping
    List<UserResponse> list();

    /**
     * 用户分页数据查询
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    PageResult<UserResponse> pageList(
            @RequestParam(value = "page", defaultValue = "1") Long pageIndex,
            @RequestParam(value = "size", defaultValue = "10") Long pageSize);

    /**
     * 用户分页数据查询
     * @param request
     * @return
     */
    @PostMapping("/query")
    PageResult<UserResponse> pageList(@RequestBody @Valid UserPageRequest request);
}